/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import java.util.GregorianCalendar;
import stamboom.Geslacht;

/**
 *
 * @author Anh
 */
public class PersoonPanel extends javax.swing.JPanel {

    /**
     * Creates new form PersoonPanel
     */
    public PersoonPanel() {
        initComponents();
    }

    public void setNummer(int nr) {
        tbNummer.setText("" + nr);
    }

    public void setAchternaam(String anaam) {
        tbAchternaam.setText(anaam);
    }

    public void setVoornamen(String vnamen) {
        tbVoornaam.setText(vnamen);
    }

    public void setTussenvoegsel(String tvoegsel) {
        tbTussenvoegsel.setText(tvoegsel);
    }

    public void setGeslacht(Geslacht g) {
        //todo
        if (g == Geslacht.MAN) {
            rbMannelijk.setSelected(true);
        } else if (g == Geslacht.VROUW) {
            rbVrouwelijk.setSelected(true);
        }
    }

    public void setGebDat(String datum) {
        jtfGebDatum.setText(datum);
    }

    public String getAchternaam() {
        if (tbAchternaam.getText().isEmpty()) {
            return null;
        } else {
            return tbAchternaam.getText();
        }
    }

    public String[] getVoornamen() {
        if (tbVoornaam.getText().isEmpty()) {
            return tbVoornaam.getText().trim().split(" ");
        } else {
            return null;
        }
    }

    public String getTussenvoegsel() {
        return tbTussenvoegsel.getText();
    }

    public Geslacht getGeslacht() {
        //todo
        if (rbMannelijk.isSelected() == true) {
            return Geslacht.MAN;
        } else {
            return Geslacht.VROUW;
        }
    }

    public GregorianCalendar getGebDat() {

        if (jtfGebDatum.getText().isEmpty()) {

            return null;

        } else {

            return Util.datum(this,
                    jtfGebDatum.getText());

        }

    }

 

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        persoonLabel = new javax.swing.JLabel();
        nummerLabel = new javax.swing.JLabel();
        achternaamLAbel = new javax.swing.JLabel();
        voornaamLabel = new javax.swing.JLabel();
        tussenvLabel = new javax.swing.JLabel();
        tbNummer = new javax.swing.JTextField();
        tbAchternaam = new javax.swing.JTextField();
        tbVoornaam = new javax.swing.JTextField();
        tbTussenvoegsel = new javax.swing.JTextField();
        rbMannelijk = new javax.swing.JRadioButton();
        rbVrouwelijk = new javax.swing.JRadioButton();
        jLabel6 = new javax.swing.JLabel();
        jtfGebDatum = new javax.swing.JTextField();
        btnVoegToe = new javax.swing.JButton();

        persoonLabel.setFont(new java.awt.Font("Lucida Grande", 1, 24)); // NOI18N
        persoonLabel.setText("Persoon");

        nummerLabel.setText("Nummer");

        achternaamLAbel.setText("Achternaam");

        voornaamLabel.setText("Voornaam");

        tussenvLabel.setText("Tussenvoegsel");

        tbNummer.setText("jTextField1");

        tbAchternaam.setText("jTextField2");

        tbVoornaam.setText("jTextField3");

        tbTussenvoegsel.setText("jTextField4");

        rbMannelijk.setText("Mannelijk");

        rbVrouwelijk.setText("Vrouwelijk");

        jLabel6.setText("Geboortedatum (dd-mm-jjjj)");

        jtfGebDatum.setText("jTextField1");

        btnVoegToe.setText("Voeg Toe");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(layout.createSequentialGroup()
                                .add(tussenvLabel)
                                .add(18, 18, 18)
                                .add(tbTussenvoegsel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE))
                            .add(layout.createSequentialGroup()
                                .add(voornaamLabel)
                                .add(45, 45, 45)
                                .add(tbVoornaam))
                            .add(layout.createSequentialGroup()
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(achternaamLAbel)
                                    .add(nummerLabel))
                                .add(33, 33, 33)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                    .add(tbNummer, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 311, Short.MAX_VALUE)
                                    .add(tbAchternaam)))))
                    .add(layout.createSequentialGroup()
                        .add(34, 34, 34)
                        .add(rbMannelijk)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(rbVrouwelijk))
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(persoonLabel))
                    .add(layout.createSequentialGroup()
                        .addContainerGap()
                        .add(btnVoegToe)))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel6)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jtfGebDatum, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 226, Short.MAX_VALUE)
                .add(128, 128, 128))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap(27, Short.MAX_VALUE)
                .add(persoonLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(nummerLabel)
                    .add(tbNummer, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(achternaamLAbel)
                    .add(tbAchternaam, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(voornaamLabel)
                    .add(tbVoornaam, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(tussenvLabel)
                    .add(tbTussenvoegsel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(rbMannelijk)
                    .add(rbVrouwelijk))
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel6)
                    .add(jtfGebDatum, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(btnVoegToe))
        );

        persoonLabel.getAccessibleContext().setAccessibleName("lblPersoon");
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel achternaamLAbel;
    private javax.swing.JButton btnVoegToe;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JTextField jtfGebDatum;
    private javax.swing.JLabel nummerLabel;
    private javax.swing.JLabel persoonLabel;
    private javax.swing.JRadioButton rbMannelijk;
    private javax.swing.JRadioButton rbVrouwelijk;
    private javax.swing.JTextField tbAchternaam;
    private javax.swing.JTextField tbNummer;
    private javax.swing.JTextField tbTussenvoegsel;
    private javax.swing.JTextField tbVoornaam;
    private javax.swing.JLabel tussenvLabel;
    private javax.swing.JLabel voornaamLabel;
    // End of variables declaration//GEN-END:variables
}
